<?php

use think\migration\Migrator;
use think\migration\db\Column;

class AppAccount extends Migrator
{
    /**
     * Change Method.
     *
     * Write your reversible migrations using this method.
     *
     * More information on writing migrations is available here:
     * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
     *
     * The following commands can be used in this method and Phinx will
     * automatically reverse them when rolling back:
     *
     *    createTable
     *    renameTable
     *    addColumn
     *    renameColumn
     *    addIndex
     *    addForeignKey
     *
     * Remember to call "create()" or "update()" and NOT "save()" when working
     * with the Table class.
     */
    public  function  change()
    {
        // create the table
        $table  =  $this->table('app_account',['engine'=>'InnoDB','id' => false, 'primary_key' => ['app_id'],'collation'=>'utf8mb4_general_ci']);
        $table->addColumn('app_id', 'string',['limit'  =>  25,'default'=>uniqid('im'),'comment'=>'AppId,授权认证ID'])
            ->addColumn('secret', 'string',['limit'  =>  32,'default'=>md5(time()),'comment'=>'用户密钥'])
            ->addColumn('limit_ip', 'string',['limit'  =>360 ,'default'=>'*','comment'=>'*:代表全部不受限制'])
            ->addColumn('off_time', 'integer',['limit'  =>  11,'default'=>0,'comment'=>'应用关闭时间,0:永久性'])
            ->addIndex(['app_id'], ['unique'  =>  true])
            ->create();
    }
}
